package com.example.administrator.foodrowfresh.models;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import org.json.JSONException;
import org.json.JSONObject;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/5/5.
 */
public class ClassifySeek {

    /**
     * success : ​1
     * data : [{"Id":"\u200b1","HotWordName":"空心菜"},{"Id":"\u200b2","HotWordName":"白萝卜"},{"Id":"\u200b3","HotWordName":"苹果"},{"Id":"\u200b4","HotWordName":"香蕉"},{"Id":"\u200b5","HotWordName":"猪肉"},{"Id":"\u200b6","HotWordName":"牛排"},{"Id":"\u200b7","HotWordName":"牛奶"},{"Id":"\u200b8","HotWordName":"酸奶"},{"Id":"\u200b9","HotWordName":"大米"}]
     */

    private String success;
    /**
     * Id : ​1
     * HotWordName : 空心菜
     */

    private List<DataBean> data;

    public static ClassifySeek objectFromData(String str) {

        return new Gson().fromJson(str, ClassifySeek.class);
    }

    public static ClassifySeek objectFromData(String str, String key) {

        try {
            JSONObject jsonObject = new JSONObject(str);

            return new Gson().fromJson(jsonObject.getString(str), ClassifySeek.class);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        return null;
    }

    public static List<ClassifySeek> arrayClassifySeekFromData(String str) {

        Type listType = new TypeToken<ArrayList<ClassifySeek>>() {
        }.getType();

        return new Gson().fromJson(str, listType);
    }

    public static List<ClassifySeek> arrayClassifySeekFromData(String str, String key) {

        try {
            JSONObject jsonObject = new JSONObject(str);
            Type listType = new TypeToken<ArrayList<ClassifySeek>>() {
            }.getType();

            return new Gson().fromJson(jsonObject.getString(str), listType);

        } catch (JSONException e) {
            e.printStackTrace();
        }

        return new ArrayList();


    }

    public String getSuccess() {
        return success;
    }

    public void setSuccess(String success) {
        this.success = success;
    }

    public List<DataBean> getData() {
        return data;
    }

    public void setData(List<DataBean> data) {
        this.data = data;
    }

    public static class DataBean {
        private String Id;
        private String HotWordName;

        public static DataBean objectFromData(String str) {

            return new Gson().fromJson(str, DataBean.class);
        }

        public static DataBean objectFromData(String str, String key) {

            try {
                JSONObject jsonObject = new JSONObject(str);

                return new Gson().fromJson(jsonObject.getString(str), DataBean.class);
            } catch (JSONException e) {
                e.printStackTrace();
            }

            return null;
        }

        public static List<DataBean> arrayDataBeanFromData(String str) {

            Type listType = new TypeToken<ArrayList<DataBean>>() {
            }.getType();

            return new Gson().fromJson(str, listType);
        }

        public static List<DataBean> arrayDataBeanFromData(String str, String key) {

            try {
                JSONObject jsonObject = new JSONObject(str);
                Type listType = new TypeToken<ArrayList<DataBean>>() {
                }.getType();

                return new Gson().fromJson(jsonObject.getString(str), listType);

            } catch (JSONException e) {
                e.printStackTrace();
            }

            return new ArrayList();


        }

        public String getId() {
            return Id;
        }

        public void setId(String Id) {
            this.Id = Id;
        }

        public String getHotWordName() {
            return HotWordName;
        }

        public void setHotWordName(String HotWordName) {
            this.HotWordName = HotWordName;
        }
    }
}
